﻿using System;
using System.Windows;
using System.Windows.Controls;
using Milkify.Input;
using Milkify.Interfaces;

namespace Milkify.Views
{
    /// <summary>
    /// Interaction logic for HomeControl.xaml
    /// </summary>
    public partial class HomeControl : Page, IRefreshableView
    {
        private PageFocusHelper mFocusHelper;

        public HomeControl()
        {
            InitializeComponent();

            mFocusHelper = new PageFocusHelper(this, ButtonToday);

            this.Loaded += new RoutedEventHandler(HomeControl_Loaded);
        }

        private void HomeControl_Loaded(object sender, RoutedEventArgs e)
        {
            // The only back entry the Home page can have is the Loading page. Remove that.
            if (NavigationService != null)
                NavigationService.RemoveBackEntry();
        }

        private void HomeButton_Click(object sender, RoutedEventArgs e)
        {
            mFocusHelper.FocusElement = sender as IInputElement;
        }

        #region IView Members

        public object ViewData
        {
            get { return DataContext; }
            set { DataContext = value; }
        }

        #endregion

        #region IRefreshableView Members

        public bool NeedsRefresh { get; set; }

        #endregion
    }
}
